package com.example.makerspace.controller.message;

import com.example.makerspace.dto.MessageDTO;
import com.example.makerspace.dto.NoticeDTO;
import com.example.makerspace.dto.PageRequest;
import com.example.makerspace.dto.Result;
import com.example.makerspace.service.MessageService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.models.auth.In;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

@Controller
@ResponseBody
@RequestMapping("/api/message")
@Api(tags = "消息模块")
public class MessageController {
    @Resource
    private MessageService messageService;

    @ApiOperation(value="后台-增加消息接口",notes ="后台-增加消息接口说明")
    @PostMapping("/addMessage")
    public Result addMessage(@RequestBody MessageDTO messageDTO) {
        return messageService.addMessage(messageDTO);
    }
    @ApiOperation(value="后台-修改消息接口",notes ="后台-修改消息接口说明")
    @PostMapping("/updateMessage")
    public Result updateMessage(@RequestBody MessageDTO messageDTO) {
        return messageService.updateMessage(messageDTO);
    }
    @ApiOperation(value="后台-删除消息接口",notes ="后台-删除消息接口说明")
    @GetMapping("/deleteMessage")
    public Result deleteMessage(@RequestParam("id") Integer id) {
        return messageService.deleteMessage(id);
    }
    @ApiOperation(value="后台-查询消息接口",notes ="后台-查询消息接口说明")
    @PostMapping("/selectMessage")
    public Result selectMessage(@RequestBody PageRequest pageRequest) {
        return messageService.selectMessage(pageRequest);
    }
    @ApiOperation(value="前台-查询消息接口",notes ="前台-查询消息接口说明")
    @PostMapping("/selectMessageByUserName")
    public Result selectMessageByUserName(@RequestBody PageRequest pageRequest) {
        return messageService.selectMessageByUserName(pageRequest);
    }
    @ApiOperation(value="前台-查询消息详情页接口",notes ="前台-查询消息接口说明")
    @GetMapping("/selectMessageDetail")
    public Result selectMessageDetail(@RequestParam("id") Integer id,@RequestParam("username")String username) {
        return messageService.selectMessageDetail(id,username);
    }

    @GetMapping("/showAllUnRead")
    public Result showAllUnRead(@RequestParam("username") String username) {
        return messageService.showAllUnRead(username);
    }
    @ApiOperation(value="前台-统计系统未读消息接口",notes ="前台-统计系统未读消息接口")
    @GetMapping("/showAllSystemUnRead")
    public Result showAllSystemUnRead(@RequestParam("username") String username) {
        return messageService.showAllSystemUnRead(username);
    }
    @ApiOperation(value="前台-统计消息通知未读消息接口",notes ="前台-统计系统未读消息接口")
    @GetMapping("/showAllNoticeUnRead")
    public Result showAllNoticeUnRead(@RequestParam("username") String username) {
        return messageService.showAllNoticeUnRead(username);
    }
}
